package com.probiz.estore.common.model.system.base;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.system.AppMenu;
import com.probiz.estore.core.model.BaseObject;

/**
 * AppMenu Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class AppMenuTbl extends BaseObject implements Serializable {

    protected Integer menuId;
	protected String menuName;
	protected String url;
	protected String title;
	protected String menuPath;
	protected Short belongTo;
	protected Integer version;
	protected Integer sortOrder=1;
	protected Short type=0;
	protected AppMenu parent;

	protected Set children = new HashSet();
	protected Set appRoles = new HashSet();

	/**
	 * Default Empty Constructor for class AppMenu
	 */
	public AppMenuTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class AppMenu
	 */
	public AppMenuTbl (
		 Integer in_menuId
        ) {
		this.setMenuId(in_menuId);
    }

	
	public AppMenu getParent () {
		return parent;
	}	
	
	public void setParent (AppMenu parent) {
		this.parent = parent;
	}
	
	/**
	 * 	 * @return Integer
	 */
	public Integer getParentId() {
		return this.getParent()==null?null:this.getParent().getParentId();
	}
	
	/**
	 * Set the parentId
	 */	
	public void setParentId(Integer aValue) {
	    if (aValue==null) {
	    	parent = null;
	    } else {
	        parent = new com.probiz.estore.common.model.system.AppMenu(aValue);
	        parent.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	public Set getChildren () {
		return children;
	}	
	
	public void setChildren (Set children) {
		this.children = children;
	}

	public java.util.Set getAppRoles () {
		return appRoles;
	}	
	
	public void setAppRoles (java.util.Set in_appRoles) {
		this.appRoles = in_appRoles;
	}
    

	/**
	 * 	 * @return Integer
     * @hibernate.id column="menuId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getMenuId() {
		return this.menuId;
	}
	
	/**
	 * Set the menuId
	 */	
	public void setMenuId(Integer aValue) {
		this.menuId = aValue;
	}	


	/**
	 * 	 * @return String
	 * @hibernate.property column="menuName" type="java.lang.String" length="256" not-null="true" unique="false"
	 */
	public String getMenuName() {
		return this.menuName;
	}
	
	/**
	 * Set the menuName
	 * @spring.validator type="required"
	 */	
	public void setMenuName(String aValue) {
		this.menuName = aValue;
	}	

	public Integer getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}

	/**
	 * 	 * @return String
	 * @hibernate.property column="url" type="java.lang.String" length="1024" not-null="false" unique="false"
	 */
	public String getUrl() {
		return this.url;
	}
	
	/**
	 * Set the url
	 */	
	public void setUrl(String aValue) {
		this.url = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="title" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getTitle() {
		return this.title;
	}
	
	/**
	 * Set the title
	 */	
	public void setTitle(String aValue) {
		this.title = aValue;
	}	

	/**
	 * 菜单层级路径	 * @return String
	 * @hibernate.property column="menuPath" type="java.lang.String" length="512" not-null="false" unique="false"
	 */
	public String getMenuPath() {
		return this.menuPath;
	}
	
	/**
	 * Set the menuPath
	 */	
	public void setMenuPath(String aValue) {
		this.menuPath = aValue;
	}	

	/**
	 * 0-后台菜单  1-前台菜单	 * @return Short
	 * @hibernate.property column="belongTo" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getBelongTo() {
		return this.belongTo;
	}
	
	/**
	 * Set the belongTo
	 * @spring.validator type="required"
	 */	
	public void setBelongTo(Short aValue) {
		this.belongTo = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	public Short getType() {
		return type;
	}

	public void setType(Short type) {
		this.type = type;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof AppMenuTbl)) {
			return false;
		}
		AppMenuTbl rhs = (AppMenuTbl) object;
		return new EqualsBuilder()
				.append(this.menuId, rhs.menuId)
						.append(this.menuName, rhs.menuName)
				.append(this.url, rhs.url)
				.append(this.title, rhs.title)
				.append(this.menuPath, rhs.menuPath)
				.append(this.belongTo, rhs.belongTo)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.menuId) 
						.append(this.menuName) 
				.append(this.url) 
				.append(this.title) 
				.append(this.menuPath) 
				.append(this.belongTo) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("menuId", this.menuId) 
						.append("menuName", this.menuName) 
				.append("url", this.url) 
				.append("title", this.title) 
				.append("menuPath", this.menuPath) 
				.append("belongTo", this.belongTo) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "menuId";
	}
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return menuId;
	}

}